<?php

require_once dirname(__FILE__).'/../lib/themeGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/themeGeneratorHelper.class.php';

/**
 * theme actions.
 *
 * @package    cpfaizenay
 * @subpackage theme
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class themeActions extends autoThemeActions
{
    private $titleBC = 'Thèmes';
    private $actionNewBC = 'Nouveau';
    private $actionEditBC = 'Modifier';
    private $url = 'category_theme';

    public function executeIndex(sfWebRequest $request) {
        parent::executeIndex($request);
        $this->showBreadCrumb();
    }

    public function executeNew(sfWebRequest $request) {
        parent::executeNew($request);
        $this->showBreadCrumb($this->actionNewBC);

        $obj = new Category();
        $obj->setType("news");
        $this->form = new CategoryForm($obj);
    }

    public function executeCreate(sfWebRequest $request) {
        parent::executeCreate($request);
        $this->showBreadCrumb($this->actionNewBC);
    }

    public function executeEdit(sfWebRequest $request) {
        parent::executeEdit($request);
        $this->showBreadCrumb($this->actionEditBC);
    }

    public function executeUpdate(sfWebRequest $request) {
        parent::executeUpdate($request);
        $this->showBreadCrumb($this->actionEditBC);
    }

    private function showBreadCrumb($action = NULL){
        if(!empty($action)){
            isicsBreadcrumbs::getInstance()->addItem($this->titleBC, $this->getController()->genUrl($this->url) );
            isicsBreadcrumbs::getInstance()->addItem($action, null);
        }else{
            isicsBreadcrumbs::getInstance()->addItem($this->titleBC, null);
        }
    }
}
